<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>验证表单</title>
	<?php
		if(!empty($_POST)) {
			$username = $_POST['username'];
			$pwd = $_POST['pwd'];
			$sex = $_POST['sex'];
			$age = $_POST['age'];
			$province = $_POST['province'];
			$message = $_POST['message'];
			$hr = $_POST['hr'];
			
			echo "username: $username <br>";
			echo "password: $pwd <br>";
			echo "sex: $sex <br>";
			echo "age: $age <br>";
			echo "province: $province <br>";
			
			$len = count($hr);
			$str = "";
			for($i = 0; $i < $len; $i++) {
				if($i == $len-1) {
					$str .= $hr[$i]."。";
				} else {
					$str .= $hr[$i]."，";
				}
			}
			echo "Hobbies: $str";
			echo "<br>";
			echo "message: $message <br>";
		}
		
	 ?>
</head>
<body>
	<form action="" method="post">
		<h1 align="center">个人信息介绍</h1>
		<hr>
		<table align="center" border="1px">
			<tr>
				<td>username:</td>
				<td>
					<input type="text" name="username" placeholder="Tom">
				</td>
			</tr>
			<tr>
				<td>Password:</td>
				<td>
					<input type="password" name="pwd" placeholder="password">
				</td>
			</tr>
			<tr>
				<td>sex:</td>
				<td>
					<input type="radio" name="sex" value="male" checked="checked">Male
					<input type="radio" name="sex" value="Female">Female
				</td>
			</tr>
			<tr>
				<td>age:</td>
				<td>
					<input type="number" min="0" name="age">
				</td>
			</tr>
			<tr>
				<td>province:</td>
				<td>
					province:
					<select name="province">
						<option value="shanghai">shanghai</option>
						<option value="beijing">beijing</option>
						<option value="jinan">jinan</option>
						<option value="jining">jining</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>Hobbies:</td>
				<td>
					<input type="checkbox" name="hr[]" value="绘画">绘画
					<input type="checkbox" name="hr[]" value="写作">写作
					<input type="checkbox" name="hr[]" value="唱歌">唱歌
					<input type="checkbox" name="hr[]" value="音乐">音乐
					<input type="checkbox" name="hr[]" value="舞蹈">舞蹈
				</td>
			</tr>
			<tr>
				<td>leave a message:</td>
				<td>
					<textarea name="message">
					</textarea>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<input type="submit" name="" value="OK">
					<input type="reset" name="" value="Reset">
				</td>
			</tr>
		</table>
	</form>
	
</body>
</html>